package com.yanqu.road.server.manger.cricket.skillhandler.startround.handler;

import com.yanqu.road.entity.cricket.helper.AddHpResult;
import com.yanqu.road.pb.cricket.CricketProto;
import com.yanqu.road.server.gameplayer.module.cricket.battle.CricketGame;
import com.yanqu.road.server.gameplayer.module.cricket.model.BattleData;
import com.yanqu.road.server.gameplayer.module.cricket.model.SkillData;
import com.yanqu.road.server.manger.cricket.skillhandler.startround.CricketSkillStartRoundStrategy;
import com.yanqu.road.utils.RandomHelper;

import java.math.BigDecimal;
import java.math.RoundingMode;

public class CricketSkill253Strategy implements CricketSkillStartRoundStrategy {

    /**
     * 技能处理-瑞年兽年兽之力： 每回合有{0}概率额外随机一次基础攻击。
     * @param cricketGame 本局对局对象
     * @param skillData 技能数据
     * @param action 我方
     * @param target 对方
     * @param roundId 第几回合
     * @param attackRoundBuilder 返回PB结构体
     * @return
     */
    @Override
    public boolean skillHandle(CricketGame cricketGame, SkillData skillData, BattleData action, BattleData target, int roundId, CricketProto.CricketAttackRound.Builder attackRoundBuilder) {
        int useRate = skillData.getSkillEffect().getP1();
        int realRate = RandomHelper.rand1000();
        if (realRate < useRate) {
            //设置2次攻击
            action.setAttTime(2);
            //添加客户端表现
            skillData.effectAmountInc();
            CricketProto.CricketBattleFrame.Builder battleFrameBuilder = cricketGame.newBattleFrameBuilder();
            battleFrameBuilder.setActionUserId(action.getUserId());
            battleFrameBuilder.setTargetUserId(target.getUserId());
            battleFrameBuilder.setSkillId(skillData.getSkillId());
            cricketGame.fillRemainHp(battleFrameBuilder);
            attackRoundBuilder.addStartRound(battleFrameBuilder);
        }
        return false;
    }
}
